home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 June / PCWorld_2004-06_cd.bin / software / vyzkuste / koolmoves / kmsetup.exe / {app} / Motion Scripts / Bounce / effect.txt
Text File  |  2002-11-07  |  1KB  |  48 lines

  1. loop = 0;
  2. loopDelay = 0;
  3. waitCharEnd = 0;
  4. mcN = "letter";
  5.  
  6. aLetters = new Array();
  7.  
  8. for (i = 0; i< numChar; i++){
  9.   aLetters[i+0] = i;
  10.   var letter =  this[mcN +i];
  11.   letter._visible = true;
  12.   letter.init = letterInit;
  13.   letter.doEffect = effect;
  14.   letter.number = i;
  15. }
  16.  
  17. function letterInit(){
  18. this.speed = this._parent.speed;
  19. this.top = this._y - this._parent.top;
  20. this.bottom = this._y + this._height /2;
  21. this.gravity = this._parent.gravity ;
  22. this.drag = this._parent.drag;
  23. this.bounce = this._parent.bounce;
  24. }
  25.  
  26. function effect(){
  27. this._y +=  this.speed;
  28. if(this._y + this._height /2 > this.bottom) {
  29.   this._y = this.bottom - this._height/2;
  30.   this.speed = -this.speed * this.bounce;
  31. }
  32. if(this._y - this._height/2 < this.top) {
  33.   this._y = this.top + this._height/2;
  34.   this.speed = -this.speed * this.bounce;
  35. }
  36. this.speed = this.speed * this.drag + this.gravity;
  37. }
  38.  
  39. function shuffle(){
  40.   return Math.floor(Math.random() * 3) -1;
  41. }
  42. if (random == 1){
  43.   aLetters.sort(shuffle);
  44. }
  45.  
  46. if (reverse == 1){
  47.   aLetters.reverse();
  48. }